﻿/************************************************************************************
Ensure that the page have a parent
/************************************************************************************/    
if (window.top.length <= 0){
    //Redirect away if this page does not have a parent
    window.location = "about:blank";
}

function cleanString(val){
    /*
    The g behind all the regex means, replace ALL instance found in string

    /\\/ = double backslash
    /\// = forward slash
    />/ = replace >
    /</ = replace <

    */

    var re = new Array(/\\/g,/\//g,/>/g,/</g,/@/g,/;/g);
    for (var i = 0; i < re.length; i++)
    {
        val = val.replace(re[i], " ");
    }
    return val
}

/************************************************************************************
As of 29 Dec 2008, this page only receives 2 parameter (loggedIn:boolean, name:string)
from WWW Server's CandidateProfileMgr/getStatus.aspx

This page is using cross site scripting to pass parameters
*************************************************************************************/
var qsParm = new Array();
function qs(){
    var query = window.location.search.substring(1);
    var parms = query.split('&');
    
    for (var i=0; i<parms.length; i++) 
    {
        var pos = parms[i].indexOf('=');
        if (pos > 0) 
        {
            var key = parms[i].substring(0,pos);
            var val = parms[i].substring(pos+1);
            qsParm[key] = val;
        }
    }
}

//qsParm['code'] = null;
//qsParm['desc'] = null;
qs();

/************************************************************************************
This is for the login panel
*************************************************************************************/
try{
    if ((qsParm["loggedIn"] != null) && (qsParm["loggedIn"] != "")){
        var loggedInVal = cleanString(qsParm["loggedIn"]);
        if (loggedInVal == "True"){
            if ((qsParm["name"] != null) && (qsParm["name"] != "")){
                var strName;
                strName = cleanString(qsParm["name"]);
                window.top.writeName(strName);
            }
            window.top.ParentShowHideLogin("none");
        }
        else{
            window.top.ParentShowHideLogin("block");
        }
    }
    else{
        window.top.ParentShowHideLogin("block");
    }
}
catch(e){}

/************************************************************************************
This is for the Register Job
*************************************************************************************/
try{
    if (window.top.document.getElementById("divApplyJob") != null){
        var loggedInVal = cleanString(qsParm["loggedIn"]);
        if (loggedInVal == "True"){
            window.top.document.getElementById("divApplyJob").style.display="none";
            window.top.document.getElementById("divApplyJobRegistered").style.display="block";
            
            if ((qsParm["name"] != null) && (qsParm["name"] != "")){
                var strName;
                strName = cleanString(qsParm["name"]);
                window.top.document.getElementById("lblApplyJobName").innerText = unescape(strName);
            }
        }
        else{
            window.top.document.getElementById("divApplyJob").style.display="block";
            window.top.document.getElementById("divApplyJobRegistered").style.display="none";
        }
    }
}
catch(e){}